package mirrormonkey.core.server;

import mirrormonkey.framework.entity.SyncEntity;

import com.jme3.network.MessageConnection;

public class DummyMappingStack extends MappingStack {

	protected ServerEntityData data;

	protected SyncEntity entity;

	protected MessageConnection connection;

	public DummyMappingStack(ServerCoreModule coreModule) {
		super(coreModule, null, null, null);
	}

	@Override
	public final boolean exists() {
		return false;
	}

	@Override
	public final MappingStack destroy() {
		return this;
	}

	@Override
	public ExistingMappingStack create() {
		return new ExistingMappingStack(module, entity, data, connection);
	}

	public final MappingStack findStack(SyncEntity entity,
			ServerEntityData dataOrDummy, MessageConnection connection) {
		this.entity = entity;
		this.connection = connection;
		data = dataOrDummy;
		ServerConnectionInfo connectionData = module.getData(connection);
		MappingStack ms = null;
		if (data.isRegistered() && connectionData != null) {
			ms = data.getStack(connection);
		}
		return ms == null ? this : ms;
	}

}